package com.ce.pms.custservice.service;

import java.util.Date;
import java.util.List;

import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;

import com.ce.pms.DBUnitTool;
import com.ce.pms.base.vo.SearchVO;
import com.ce.pms.custservice.dao.ITrackRecordDao;
import com.ce.pms.custservice.vo.TrackRecordVO;
import com.ce.pms.exception.BusinessException;
import com.sitechasia.webx.core.support.Page;
/**
 * 功能描述: 事件跟踪Service功能测试类
 * <p>版权所有：中企动力
 * <p>未经本公司许可，不得以任何方式复制或使用本程序任何部分
 *
 * @author  胡煦
 * Create on:2008-12-25
 * Edit author:
 * Edit on:
 * 修改原因：

 */

public class TrackRecordServiceImplT extends DBUnitTool {
	private static ITrackRecordService trackRecordService;
	private static ITrackRecordDao trackRecordDao;


	/**
	 * 方法描述: 根据ID查询TrackRecordVO方法
	 *
	 * @author 胡煦 Create on:2008-12-24
	 * @param id
	 * @return TrackRecordVO
	 * @roseuid 49436CB30186
	 */
	@Test
	public void testGetTrackRecordVOByID() {
		Long csEventID = 1l;
		TrackRecordVO TrackRecordVO = trackRecordService.getTrackRecordVOByID(csEventID);
		Assert.assertNotNull(TrackRecordVO);
	}

	/**
	 * 方法描述: 查询TrackRecordVOList方法
	 *
	 * @author 胡煦 Create on:2008-12-24
	 * @param csEventID
	 * @return List<TrackRecordVO>
	 * @roseuid 49436CB301A5
	 */
	@Test
	public void testQueryTrackRecordVOList() {
		Long csEventID = 1l;
		List<TrackRecordVO> trackRecordVOList = trackRecordService.queryTrackRecordVOList(csEventID);
		Assert.assertNotNull(trackRecordVOList);
	}

	/**
	 * 方法描述: 分页查询TrackRecordVO方法
	 *
	 * @author 胡煦 Create on:2008-12-24
	 * @param search
	 * @return Page
	 * @roseuid 49436CB301C5
	 */
	@Test
	public void testQueryTrackRecordByPage() {
		Long csEventID =1l;
		SearchVO search = new SearchVO(null,1,5);
		Page page = trackRecordService.queryTrackRecordByPage(csEventID, search);
		Assert.assertNotNull(page);
	}

	/**
	 * 方法描述: 事件跟踪新增方法
	 *
	 * @author 胡煦 Create on:2008-12-24
	 * @param nameStr：查询条件班级名称
	 * @return 返回当前页的查询结果 Edit author: Edit on: 修改原因：
	 */
	@Test
	public void testAddQuestionair() {
		Long csEventID = 1l;
		TrackRecordVO trackRecordVO = new TrackRecordVO();
		trackRecordVO.setClient("测试一");
		trackRecordVO.setCreator(1l);
		trackRecordVO.setCustomerServiceEventID(1l);
		trackRecordVO.setRecordTime(new Date());
		trackRecordVO.setRecorder("tester");
		trackRecordVO.setEventNo("110");
		trackRecordVO.setHouseID(1l);
		trackRecordVO.setHouseNumber("ceshi");
		try {
			trackRecordVO = trackRecordService.addQuestionair(csEventID, trackRecordVO);
			Assert.assertNotNull(trackRecordVO);
		} catch (BusinessException e) {
			e.printStackTrace();
			super.dealBusinessException(e, "custservice:custservice_trackrecord_add_exception");
		}
	}

	/**
	 * 方法描述: 事件跟踪新增合法性验证方法
	 *
	 * @author 胡煦 Create on:2008-12-24
	 * @param csEventID
	 * @return void Edit author: Edit on: 修改原因：
	 */
	@Test
	public void testCheckAddQuestionairIsTtue() {
		Long csEventID = 1l;
		try {
			trackRecordService.checkAddQuestionairIsTtue(csEventID);
		}  catch (BusinessException e) {
			e.printStackTrace();
			super.dealBusinessException(e, "custservice:custservice_trackrecord_add_exception");
		}
	}

	/**
	 * 方法描述: 事件跟踪作废方法
	 *
	 * @author 胡煦 Create on:2008-12-24
	 * @param trackRecordVO
	 * @return TrackRecordVO
	 * @roseuid 4928189503B9
	 */
	@Test
	public void testSetAside() {
		Long csEventID = 1l;
		TrackRecordVO trackRecordVO = new TrackRecordVO();
		trackRecordVO.setKeyword(50l);
		trackRecordVO.setModifier(1l);
		trackRecordVO.setCustomerServiceEventID(1l);
		trackRecordVO.setRemark("测试作废");
		try {
			trackRecordVO = trackRecordService.setAside(csEventID, trackRecordVO);
		} catch (RuntimeException e) {
			e.printStackTrace();
			Assert.fail("抛出业务异常");
		}
	}

	/**
	 * 方法描述: 事件跟踪作废合法性验证方法
	 *
	 * @author 胡煦 Create on:2008-12-24
	 * @param csEventID,trackRecordId
	 * @return TrackRecordDO Edit author: Edit on: 修改原因：
	 */
	@Test
	public void testCheckSetAsideIsTtue(){
		Long csEventId = 1l;
		Long trackRecordId = 50l;
		try {
			trackRecordService.checkSetAsideIsTtue(csEventId, trackRecordId);
		} catch (RuntimeException e) {
			e.printStackTrace();
			Assert.fail("抛出业务异常");
		}
	}

	/**
    *
    * 功能描述:   <br>
    *
    * Create author：胡煦  <br>
    * Create on:2008-12-17  <br>
    * Edit author：  <br>
    * Edit on:    <br>
    * Why:     <br>
    */
	@BeforeClass
	public static void initTrackRecord(){
		if (trackRecordService == null) {
			trackRecordService = (ITrackRecordService)DBUnitTool.applicationContext.getBean("trackRecordService");
		}
		if (trackRecordDao == null) {
			trackRecordDao = (ITrackRecordDao)DBUnitTool.applicationContext.getBean("trackRecordDao");
		}
	}
}
